﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SimpleTaskManager.Domain.SampleData;

namespace SimpleTaskManager.WebUI.Controllers
{
    /// <summary>
    /// The controller responsible for the main screen
    /// </summary>
    public class HomeController : Controller
    {
        //
        // GET: /Home/
        /// <summary>
        /// If it is the first run then redirects to the setup page otherwise to the dashboard.
        /// </summary>
        /// <returns>Redirect to setup or dashboard.</returns>
        public ActionResult Index()
        {
            if (Initializer.IsFirstRun(new Domain.Concrete.EFDbContext()))
                return RedirectToAction("Index", "Setup");


            return RedirectToAction("Dashboard");
        }

        /// <summary>
        /// Renders the home (Home/Index) view.
        /// </summary>
        /// <returns>The rendered view.</returns>
        [Authorize]
        public ActionResult Dashboard()
        {
            return View("Index");
        }

    }
}
